//
//  YAEncode.m
//  YASDK
//
//  Created by work-zyk on 2019/1/28.
//  Copyright © 2019 郑逸凯. All rights reserved.
//

#import "YAEncode.h"

@implementation YAEncode


//编码
+(NSString*)encodeString:(NSString*)uncodeString
{
    //    return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef) uncodeString,NULL,(CFStringRef) @"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8));
    
    return (NSString *)CFBridgingRelease((__bridge CFTypeRef _Nullable)([[uncodeString description] stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@"!*'();:@&=+$,/?%#[]"] invertedSet]]));
}
//解码
+(NSString*)decodeString:(NSString*)decodeString
{
    //    return (NSString *)CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL,(__bridge CFStringRef)decodeString,CFSTR(""),CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)));
    
    return (NSString *)CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapes(kCFAllocatorDefault, (CFStringRef)decodeString, CFSTR("")));
}

@end
